<template>
<div id="app-container">
  <el-button type="primary" @click="showDrawer">弹出抽屉</el-button>
  <el-drawer
      title="我是标题"
      :visible.sync="drawer"
      :direction="direction"
      :size="'50%'"
      :before-close="handleClose">
    <el-container>
      <el-header>Header</el-header>
      <el-main>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="活动名称">
            <el-input v-model="form.name" :autofocus="focus"></el-input>
          </el-form-item>
          <el-form-item label="活动形式">
            <el-input type="textarea" v-model="form.desc"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">立即创建</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </el-main>
      <el-footer>Footer</el-footer>
    </el-container>
  </el-drawer>
</div>
</template>

<script>
export default {
  name: "MyDrawer",
  data() {
    return {
      drawer: false,
      direction: 'rtl',
      focus: true, // 这种方式, 就不自动聚焦 ???
      form: {
        name: '活动名称-001',
        desc: '活动形式-002'
      }
    };
  },
  methods: {
    showDrawer() {
      this.drawer = true
    },
    handleClose() {
      this.drawer = false
    },
    onSubmit() {
      console.log('submit!');
    }
  }
}
</script>

<style scoped>

</style>